package com.itheima.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.DTO.ClazzDTO;
import com.itheima.pojo.Clazz;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author ch200
 * @description 针对表【clazz(班级表)】的数据库操作Mapper
 * @createDate 2025-03-11 19:10:42
 * @Entity com.itheima.pojo.Clazz
 */
@Mapper
public interface ClazzMapper extends BaseMapper<Clazz> {




    @Select("select c.*,e.name masterName," +
            "(case when c.begin_date>now() then '未开班' " +
            "when c.begin_date<=now() and c.end_date>=now() then '在读' " +
            "else '已结课' end ) as status  " +
            "from clazz c  left join emp e on c.master_id=e.id ")
    Page<Clazz> page( Page<Clazz> p, @Param("ew") QueryWrapper<Clazz> wrapper);


    @Select("select  distinct c.id, c.name, c.room, c.begin_date, c.end_date, c.master_id, c.subject, c.create_time, c.update_time from  student s join  clazz c on  s.clazz_id=c.id")
    List<Clazz> selecClazztList();

}




